<?php
	namespace app\controllers\test_study;
	use yii\web\Controller;
	use app\models\test_study\orders;
	use app\models\test_study\customers;
	class SqlxingnengController extends Controller{
		public function actionIndex(){
			$customer = customers::find()->where(['name'=>'zhangsan'])->one();
			$order = $customer->orders;
			unset($customer->orders);//清除缓存，不然下一个赋值会直接给$orders里面的值
			$order2 = $customer->orders;//因上面的unset会重新连接数据库查询

			$customers = customers::find()->all();
			//下面返回customer以及多了一个orders对应id的值
			$orders = customers::find()->with('orders')->asArray()->all();
			print_R($orders);
			/*foreach($customers as $customer){

			}
			print_R($customers);*/
		}
	}
?>